##############################################################
#Figure C2: Distribution of Risk Aversion in CCES 2014
##############################################################

data <- read.dta("./input/cces-subset.dta")

smalld <- data[,c("employed", "out_of_labour", "race_14", "risk", "dem14", "education", 
                  "female", "income", "income_quarters", "age")]

smalld$income <- as.factor(smalld$income)
smalld$income_quarters <- as.factor(smalld$income_quarters)
smalld$education <- as.factor(smalld$education)


smalld$risk <- as.factor(smalld$risk)
out <- as.data.frame(prop.table(table(smalld$risk)))

ggplot(out, aes(as.factor(Var1), Freq)) + 
  geom_bar(stat="identity", fill= "grey60") + 
  theme_classic() + 
  ylab("Percent") + xlab("Risk Aversion") + 
  scale_x_discrete(labels=c("Risk Taker", " ", " ", "Risk Averse")) + 
  theme(panel.background = element_blank(), 
        axis.line.x = element_blank(),
        axis.ticks.x = element_blank()) + 
  scale_y_continuous(breaks=c(0,0.1,.2,.3,.4,.5,.6), limits=c(0,0.6), expand=c(0,0))
ggsave("./figures/figc2.pdf")